Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore vlan attachment API responses "422 Virtual network foo already…" #62

Merged

Conversation

displague
Copy link
Collaborator

Description of your changes

During conformance testing, attachment resources would reach un unready state, despite being ready.

vents:
  Type     Reason                           Age                    From                                        Message
  ----     ------                           ----                   ----                                        -------
  Warning  CannotResolveResourceReferences  2m9s (x10 over 2m11s)  managed/assignment.ports.metal.equinix.com  cannot resolve references: referenced field was empty (referenced resource may not yet be ready)
  Warning  CannotCreateExternalResource     119s (x3 over 2m6s)    managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 still bonded
  Normal   CreatedExternalResource          81s                    managed/assignment.ports.metal.equinix.com  Successfully requested creation of external resource
  Warning  CannotCreateExternalResource     39s (x3 over 80s)      managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned

Checklist

I have:

  • Run make reviewable to ensure this PR is ready for review.
  • Ensured this PR contains a neat, self documenting set of commits.
  • Updated any relevant documentation, examples, or release notes.

// Virtual network 1182 already unassigned"
func IsAlreadyDone(err error) bool {
if e, ok := err.(*packngo.ErrorResponse); ok && e.Response != nil {
return e.Response.StatusCode == http.StatusUnprocessableEntity &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is status code 422 enough to identify this error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

I am also checking the text included in the error message (the bold elements are being checked):


422 Unprocessable Entity
{"error":"Virtual Network 1234 already attached"}


This will also capture "Virtual Network 1234 already unattached"
(I was originally checking for the text in the wrong place, StatusCode vs errsInOne. Fixed in the latest commits).

… ..."

Signed-off-by: Marques Johansson <mjohansson@equinix.com>
Signed-off-by: Marques Johansson <mjohansson@equinix.com>
Signed-off-by: Marques Johansson <mjohansson@equinix.com>
@displague
Copy link
Collaborator Author

kubectl get crossplane  
NAME                                                        INSTALLED   HEALTHY   PACKAGE                                                     AGE
provider.pkg.crossplane.io/equinix-provider-equinix-metal   True        True      registry.upbound.io/equinix/provider-equinix-metal:v0.0.7   97m

NAME                                                                             HEALTHY   REVISION   IMAGE                                                       STATE    DEP-FOUND   DEP-INSTALLED   AGE
providerrevision.pkg.crossplane.io/equinix-provider-equinix-metal-4fed94a7a957   True      1          registry.upbound.io/equinix/provider-equinix-metal:v0.0.7   Active                               97m

NAME                                                                 READY   SYNCED   ID                                     RECLAIM-POLICY   AGE
assignment.ports.metal.equinix.com/crossplane-example-eth1-xp-vlan   True    True     7f67f7da-8302-4b5c-afd2-df0babc02208                    90m

NAME                                            READY   SYNCED   ID                                     FACILITY   RECLAIM-POLICY   AGE
virtualnetwork.vlan.metal.equinix.com/xp-vlan   True    True     120a2342-d561-4ebc-957d-8b1de678dff0   sv15                        90m

NAME                                                 READY   SYNCED   STATE    ID                                     HOSTNAME             FACILITY   IPV4           RECLAIM-POLICY   AGE
device.server.metal.equinix.com/crossplane-example   True    True     active   e0d0ea1e-889d-413c-a2e4-c294979643ac   crossplane-example   sv15       86.109.1.247                    90m

NAME                                                      AGE
providerconfig.metal.equinix.com/equinix-metal-provider   97m

NAME                                                                         AGE   CONFIG-NAME              RESOURCE-KIND    RESOURCE-NAME
providerconfigusage.metal.equinix.com/3f9a5f2a-8f12-4afe-a8a9-81457da778e8   49m   equinix-metal-provider   VirtualNetwork   xp-vlan
providerconfigusage.metal.equinix.com/66e6c7a8-d56a-46f7-bdc7-c0c6132052fb   49m   equinix-metal-provider   Device           crossplane-example
providerconfigusage.metal.equinix.com/ee8daaf2-2f7b-4654-9cdc-951402a313e2   49m   equinix-metal-provider   Assignment       crossplane-example-eth1-xp-vlan
Status:
  Conditions:
    Last Transition Time:  2021-06-11T21:32:50Z
    Reason:                ReconcileSuccess
    Status:                True
    Type:                  Synced
    Last Transition Time:  2021-06-11T21:39:24Z
    Reason:                Available
    Status:                True
    Type:                  Ready
Events:
  Type     Reason                           Age                 From                                        Message
  ----     ------                           ----                ----                                        -------
  Warning  CannotResolveResourceReferences  58m (x10 over 58m)  managed/assignment.ports.metal.equinix.com  cannot resolve references: referenced field was empty (referenced resource may not yet be ready)
  Warning  CannotCreateExternalResource     57m (x3 over 58m)   managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 still bonded
  Normal   CreatedExternalResource          57m                 managed/assignment.ports.metal.equinix.com  Successfully requested creation of external resource
  Warning  CannotCreateExternalResource     40m (x5 over 57m)   managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Warning  CannotCreateExternalResource     33m (x13 over 34m)  managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Warning  CannotCreateExternalResource     29m (x13 over 30m)  managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Warning  CannotCreateExternalResource     28m (x11 over 28m)  managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Warning  CannotCreateExternalResource     23m (x7 over 23m)   managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Warning  CannotCreateExternalResource     22m (x3 over 22m)   managed/assignment.ports.metal.equinix.com  cannot create Assignment: POST https://api.equinix.com/metal/v1/ports/7f67f7da-8302-4b5c-afd2-df0babc02208/assign: 422 Virtual network 1182 already assigned
  Normal   CreatedExternalResource          18m (x16 over 21m)  managed/assignment.ports.metal.equinix.com  Successfully requested creation of external resource
  Normal   CreatedExternalResource          16m (x3 over 16m)   managed/assignment.ports.metal.equinix.com  Successfully requested creation of external resource

@displague displague merged commit fd7045e into crossplane-contrib:master Jun 14, 2021
@displague displague deleted the ignore-422-vlan-already branch June 14, 2021 12:13
@displague displague linked an issue Jun 14, 2021 that may be closed by this pull request
@displague displague mentioned this pull request Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VLAN Assignments do not handle 422 when already assigned
2 participants